package com.zelin.service.impl;

import com.zelin.pojo.Product;
import com.zelin.dao.ProductDao;
import com.zelin.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by WF on 2020/10/29 10:57
 */
@Service
public class ProductServiceImpl implements ProductService {
    @Autowired
    private ProductDao productDao;
    //1.添加商品
    @Override
    public void add(Product product) {
        productDao.save(product);
    }

    //2.根据id商品商品
    @Override
    public Product findById(Integer pid) {
        return productDao.findById(pid).get();
    }

    //3.查询所有商品
    @Override
    public List<Product> findAll() {
        return productDao.findAll();
    }
}
